<?php

class AdminRouter implements RouterInterface
{
    static public function route($path_parts = array())
    {
        session_start();

        if (!empty($path_parts))
        {
            self::routeDeeper($path_parts);
        }
        else
        {
            $designatedController = new AdminLoginController();
            $designatedController->defaultAction();
        }
    }

    static public function routeDeeper($path_parts = array())
    {
        if (!empty($path_parts[0]))
        {
            switch ($path_parts[0])
            {
                case 'user':
                    $second_part = array_shift($path_parts);
                    $designatedController = new AdminUserController();

                    if (isset($path_parts[0]) && !empty($path_parts[0]))
                    {
                        $designatedController->$path_parts[0]();
                    }
                    else
                    {
                        $designatedController->defaultAction();
                    }
                    break;
                case 'login':
                    $designatedController = new AdminLoginController();
                    $designatedController->defaultAction();
                    break;
                default:
                    // nemoguce
                    break;
            }
        }
        else
        {
            $designatedController = new AdminLoginController();
            $designatedController->defaultAction();
        }
    }
}

?>